//
// Created by 紫霄 on 2020/4/15.
//

#ifndef LEETCODE_191_H
#define LEETCODE_191_H
#include <bitset>
#include <cstdint>
using namespace std;
class Solution {
public:
  int hammingWeight(uint32_t n) {
    return bitset<32>(n).count();
    int i = 32;
    int cnt = 0;
    while (i--) {
      if (n & 1) {
        ++cnt;
      }
      n >>= 1;
    }
    return cnt;
  }
};
#endif // LEETCODE_191_H
